use sha3::{Digest, Sha3_256};
use std::fmt::Write;

// 获取hash
pub fn get_hash(data: &[u8]) -> Vec<u8> {
    let mut hash = Vec::new();

    let mut hasher = Sha3_256::new();

    Digest::update(&mut hasher, data);
    hash = Digest::finalize_reset(&mut hasher).to_vec();
    hash
}

// 字节数组转16进制
pub fn hex_string(vec: &Vec<u8>) -> String {
    let mut s = String::new();
    for byte in vec {
        write!(&mut s, "{:02x}", byte).expect("Unable to write");
    }
    s
}





